<?php
include_once(dirname(__FILE__)."/../ZadminGallery.php");
class ZalbumController extends FrontController
{	
	public static $initialized = false;
	public $album;
	public $errors;
	public function __construct() {
		global $cookie;
		
		
		parent::__construct();
	}

	public function setMedia()
	{
		parent::setMedia();
		$id_pl_gp_album = ((int)(Tools::getValue('i')));
		if (!$id_pl_gp_album) $id_pl_gp_album = 1;
		$album = Zalbum::getNameAlbumCurrent($id_pl_gp_album);
		self::$smarty->assign(array(
			'meta_title'=> $album,
			'meta_description' => 'Photo',
		));
//		*********************JS Show Box*******************************************
		Tools::addJS(_MODULE_DIR_.'zgallery/js/prettyPhoto/jquery.prettyPhoto.js');
//		*********************css Show Box*******************************************
		Tools::addCSS(_MODULE_DIR_.'zgallery/css/prettyPhoto/prettyPhoto.css');
		Tools::addCSS(_MODULE_DIR_.'zgallery/css/gallery.css');
	}
	public function process()
	{
		global $cookie;
				
		$id_pl_gp_album = ((int)(Tools::getValue('i')));
		if (!$id_pl_gp_album) $id_pl_gp_album = 1;
		
		$id_photo = ((int)(Tools::getValue('v')));
		if (!$id_photo) $id_photo = 1;
		$nb = Zalbum::getNumberPhoto($id_pl_gp_album);
		self::$smarty->assign(array (
			'id_pl_gp_album' => $id_pl_gp_album ,
			'id_photo' => $id_photo,
			'nbphoto' => $nb
		));
	}
		
	public function displayContent() 
	{
		self::$smarty->display(_PS_MODULE_DIR_.'zgallery/views/zgalleryAlbum.tpl');
	}
	
	public function displayFooter()
	{

		if (!self::$initialized)
			$this->init();

		self::$smarty->assign(array(
			'HOOK_RIGHT_COLUMN' => NULL,
			'HOOK_FOOTER' => Module::hookExec('footer'),
			'content_only' => 1));
		self::$smarty->display(_PS_THEME_DIR_.'footer.tpl');
		//live edit
		if (Tools::isSubmit('live_edit') AND $ad = Tools::getValue('ad') AND (Tools::getValue('liveToken') == sha1(Tools::getValue('ad')._COOKIE_KEY_)))
		{
			self::$smarty->assign(array('ad' => $ad, 'live_edit' => true));
			self::$smarty->display(_PS_ALL_THEMES_DIR_.'live_edit.tpl');
		}
		else
			Tools::displayError();
	}
}